package com.classroom;

public class Text02 {
    public static void main(String[] args) {
        String name = "123.jpg";
        //当前系统的ms值
        long time = System.currentTimeMillis();

        method1(name, time);
        method2(name, time);


    }


    //字符串的截取获得
    private static void method2(String name, long time) {
        String[] split = name.split("\\.", 2);
        System.out.println(time + "." + split[1]);
    }

    private static void method1(String name, long time) {
        //先获取最后一个.的位置
        int i = name.lastIndexOf(".");

        //利用字符串的截取最后的后缀
        String substring = name.substring(i);

        //拼接时间戳
        name = time + substring;
        System.out.println(name);
    }
}
